#include "recodewidget.h"

RecodeWidget::RecodeWidget(int time)
{
    resize(300,200);
    QPixmap WindowPix;
    WindowPix.load(":/res/bomb.png");
    this->setWindowIcon(QIcon(WindowPix));
    this->setWindowTitle("胜利");

    QLabel* infoLabel = new QLabel(this);
    infoLabel->move(0.5*(this->width()-infoLabel->width()),this->height()*0.3);
    infoLabel->setText("请输入昵称:");
    //名字编辑框
    QLineEdit* nameEdit = new QLineEdit(this);
    nameEdit->move(0.5*(this->width()-nameEdit->width()),this->height()*0.4);
    //确定按钮
    QPushButton* confirmBtn = new QPushButton(this);
    confirmBtn->setFixedSize(60,30);
    confirmBtn->setText("确定");
    confirmBtn->move(0.5*(this->width()-confirmBtn->width()),this->height()*0.8);

    connect(confirmBtn,&QPushButton::clicked,[=](){
        QFile file(".\\recode.txt");
        double realtime = time*0.1;
        QString str = nameEdit->text()+'\t'+QString::number(realtime)+'\n';
        file.open(QIODevice::Append);
        file.write(str.toUtf8().data());
        file.close();
        delete this;
    });
}
